import 'package:flutter/material.dart';
import 'package:second_hand/pages/profile/profile.dart';

import '../add_goods.dart';
import 'HomePage/HomePage.dart';

//首页下方导航栏
List<Widget> tabViewList = [
  const HomePage(),
  const AddGoodsPage(),
  const Placeholder(),
  const ProfilePage(),
];

List<BottomNavigationBarItem> barItemList = [
  const BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
  const BottomNavigationBarItem(icon: Icon(Icons.add), label: '发布'),
  const BottomNavigationBarItem(icon: Icon(Icons.message), label: '消息'),
  const BottomNavigationBarItem(icon: Icon(Icons.person), label: '我的'),
];

class NavigatorHomePage extends StatefulWidget {
  const NavigatorHomePage({super.key});

  @override
  State<NavigatorHomePage> createState() => _NavigatorHomePageState();
}

class _NavigatorHomePageState extends State<NavigatorHomePage> {
  int _selectedIndex = 0;

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: tabViewList[_selectedIndex],
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Colors.white,
        type: BottomNavigationBarType.fixed,
        items: barItemList,
        currentIndex: _selectedIndex,
        selectedItemColor: Colors.blue,
        onTap: _onItemTapped,
      ),
    );
  }
}
